import { ResPage, User } from "@/api/interface/index";
import { TreePort } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 用户管理模块
 */
// 获取区域列表
export const getUserList = (params: User.ReqUserParams) => {
  console.log(params, "params");
  return http.post<ResPage<User.ResUserList>>(TreePort + `/user/pageList`, {
    page: params.page,
    pageSize: params.pageSize,
    search_key: {
      name: params.name,
      status: params.status,
      account: params.account,
      mobile: params.mobile,
      memo: params.memo,
      created_at: params.created_at,
      updated_at: params.updated_at
    }
  });
};

// 新增用户
export const addUser = (params: object) => {
  return http.post(TreePort + `/user/add`, params);
};

// 编辑区域
export const editUser = (params: object) => {
  return http.post(TreePort + `/user/update`, { ...params });
};

// 删除用户
export const deleteUser = (params: { user_id: string }) => {
  return http.post(TreePort + `/user/delete`, params);
};

// 切换用户状态
export const updateUserStatus = (params: { user_id: number; status: number }) => {
  return http.post(TreePort + `/user/updateStatus`, params);
};
